/*
Authors: Eli Yucht 300388949 and Lior Fass 300069705
Project: SCP (Switch Schedule Policy)
Description: flow class
*/


#ifndef LIST_OF_FLOWS_H
#define LIST_OF_FLOWS_H

#include <iostream>
using namespace std;

#define MAX_IP_ADD_LEN 16
#define BUF_SIZE 50 // sufficient room for 2 long int + space + NULL terminator

struct Packet
{
	long int pktID,arrive_time;
	char* sadd, *dadd;
	unsigned short int sport, dport, length, weight;
	Packet* next_packet;
	Packet()
	{
		pktID = -1;
		arrive_time = -1;
		sadd = NULL;
		dadd = NULL;
		sport = -1;
		dport = -1;
		length = -1;
		weight = -1;
		next_packet = NULL;
	}
}; 


// Flow class declaration
class Flow
{
public:
	Flow(char* sadd,unsigned short int sport,char* dadd,
		unsigned short int dport,unsigned short int wgt);
	~Flow();
	bool Check_Flow(char* sadd, unsigned short int sport, char* dadd, unsigned short int dport);
	int Add_Pkt_To_Flow(long int pktID, long int arrived_time, unsigned short int length);
	long int Remove_Pkt_From_Flow(long int time, FILE* outfile_p);
	unsigned short int getWeight();
	void AddCredit(int quantum);
	void ReduceCredit();
	void ZerorizeCredit();
	int GetCredit();
	unsigned short int Get1PacketLength();
	Flow* next_flow;

private:
	char src_ip_add[MAX_IP_ADD_LEN];
	char des_ip_add[MAX_IP_ADD_LEN];
	unsigned short int src_port;
	unsigned short int des_port;
	unsigned short int weight;
	unsigned short int credit;

	Packet* head_packet_queue;
	Packet* tail_packet_queue;
	

};

#endif // LIST_OF_FLOWS_H